import request from '@/utils/request'

/**
 * 获取用户列表
 */
export const getUserListApi = (query,currentPage,pageSize) => {

    return request({
        url: '/user/list',
        method: 'get',
        params: {
            query: query,
            currentPage: currentPage,
            pageSize: pageSize
        }
    })
}

/**
 * 改变用户状态
 */
export const changeUserStatusApi = (id,status,roleNames) => {

    return request({
        url: '/user/changeStatus',
        method: 'post',
        data:
        new URLSearchParams({
            id: id,
            status: status,
            roleNames: roleNames.join(',')
        }).toString()  // 转换为表单格式
    })
}
/**
 * 删除用户
 */
export const deleteUserApi = (id,roleNames) => {

    return request({
        url: '/user/delete',
        method: 'delete',
        params: {
            id: id,
            roleNames: roleNames.join(',')
        }
    })
  }

/**
 * 修改用户
 */
export const updateUserApi = (id,email,password) => {

    return request({
        url: '/user/update',
        method: 'patch',
        data:
        new URLSearchParams({
            id: id,
            email: email,
            password: password,
        }).toString() // 转换为表单格式
    })
}
